/*
* ov_detector.h
* Created on: 20230605
* Author: sumang
* Description: armor detector of openvino
*/
#ifndef OV_DETECT_H_
#define OV_DETECT_H_

#ifndef USE_NVIDIA
#else 
#include <inference_engine.hpp>
#include "detector.h"
#include "common_structs.h"

class OvO_Detector:public MyDetector 
{
private:
    InferenceEngine::Core ie_;
    InferenceEngine::CNNNetwork network_;
    InferenceEngine::ExecutableNetwork executable_network_;
    InferenceEngine::InferRequest infer_request_;
    std::vector<float> blob; 
    std::string input_name_;
    std::vector<s_OutLayer> output_layers_;
    std::vector<std::string> output_names_;
    std::vector<float> anchors_[4];
    
    void copyBlob(std::vector<float>& blob, InferenceEngine::Blob::Ptr& ieBlob);
    void decode_outputs(const float *prob, s_detections &objects,
                              s_OutLayer& layer_info, const int img_w,
                              const int img_h);
    void do_merge_nms();
    void preprocess() override;
    void inference() override;
    void postprocess() override;
    

public:
    std::vector<s_armor> output_nms_;
    OvO_Detector(){};
    ~OvO_Detector(){};
    void OvO_Init();
    bool detect();

};
inline float sigmoid(float x) { return (1.0 / (1.0 + exp(-x))); }

/**
 * @brief calculate sigmoid values in an array
 * 
 * @param src pointer of source array
 * @param dst pointer of destination array
 * @param length number of values
 */
inline void sigmoid(const float *src, float *dst, int length) {
    for (int i = 0; i < length; ++i) {
        dst[i] = (1.0 / (1.0 + exp(-src[i])));
    }
}
#endif

#endif
